/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alessandro
 */
@Entity
@Table(name = "ORCAMENTO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Orcamento.findAll", query = "SELECT o FROM Orcamento o"),
    @NamedQuery(name = "Orcamento.findByIdOrcamento", query = "SELECT o FROM Orcamento o WHERE o.idOrcamento = :idOrcamento"),
    @NamedQuery(name = "Orcamento.findByDataEmissao", query = "SELECT o FROM Orcamento o WHERE o.dataEmissao = :dataEmissao")})
public class Orcamento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_orcamento")
    private Integer idOrcamento;
    @Basic(optional = false)
    @NotNull
    @Column(name = "data_emissao")
    @Temporal(TemporalType.DATE)
    private Date dataEmissao;
    @JoinColumn(name = "cod_doutor", referencedColumnName = "id_doutor")
    @ManyToOne(optional = false)
    private Doutor codDoutor;
    @JoinColumn(name = "cod_cliente", referencedColumnName = "id_pessoa")
    @ManyToOne(optional = false)
    private Pessoa codCliente;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codOrcamento")
    private List<ServicoOrcamento> servicoOrcamentoList;

    public Orcamento() {
    }

    public Orcamento(Integer idOrcamento) {
        this.idOrcamento = idOrcamento;
    }

    public Orcamento(Integer idOrcamento, Date dataEmissao) {
        this.idOrcamento = idOrcamento;
        this.dataEmissao = dataEmissao;
    }

    public Integer getIdOrcamento() {
        return idOrcamento;
    }

    public void setIdOrcamento(Integer idOrcamento) {
        this.idOrcamento = idOrcamento;
    }

    public Date getDataEmissao() {
        return dataEmissao;
    }

    public void setDataEmissao(Date dataEmissao) {
        this.dataEmissao = dataEmissao;
    }

    public Doutor getCodDoutor() {
        return codDoutor;
    }

    public void setCodDoutor(Doutor codDoutor) {
        this.codDoutor = codDoutor;
    }

    public Pessoa getCodCliente() {
        return codCliente;
    }

    public void setCodCliente(Pessoa codCliente) {
        this.codCliente = codCliente;
    }

    @XmlTransient
    public List<ServicoOrcamento> getServicoOrcamentoList() {
        return servicoOrcamentoList;
    }

    public void setServicoOrcamentoList(List<ServicoOrcamento> servicoOrcamentoList) {
        this.servicoOrcamentoList = servicoOrcamentoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idOrcamento != null ? idOrcamento.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Orcamento)) {
            return false;
        }
        Orcamento other = (Orcamento) object;
        if ((this.idOrcamento == null && other.idOrcamento != null) || (this.idOrcamento != null && !this.idOrcamento.equals(other.idOrcamento))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pojo.Orcamento[ idOrcamento=" + idOrcamento + " ]";
    }
    
}
